package com.atgouwu.aiparent.springai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/qwen")
public class QwenController {

    private final ChatClient chatClient;

    public QwenController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @GetMapping("/chat")
    public String chat(@RequestParam String message) {
        String res = chatClient.prompt()
                .user(message)  //用户消息
                .call()  //同步调用
                .content();  //直接获取响应内容（字符串）
        return res;
    }

}
